﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.Buttons.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style BasedOn="{StaticResource SquareButtonStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
    </Style>

    <Style x:Key="AccentedDialogSquareButton"
           BasedOn="{StaticResource AccentedSquareButtonStyle}"
           TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
    </Style>

    <Storyboard x:Key="DialogShownStoryboard">
        <DoubleAnimation AccelerationRatio=".9"
                         BeginTime="0:0:0"
                         Duration="0:0:0.2"
                         Storyboard.TargetProperty="Opacity"
                         To="1" />
    </Storyboard>

    <Storyboard x:Key="DialogCloseStoryboard">
        <DoubleAnimation AccelerationRatio=".9"
                         BeginTime="0:0:0"
                         Duration="0:0:0.2"
                         Storyboard.TargetProperty="Opacity"
                         To="0" />
    </Storyboard>

    <ControlTemplate x:Key="MetroDialogTemplate"
                     TargetType="{x:Type Dialogs:BaseMetroDialog}">
        <Grid Background="{TemplateBinding Background}">
            <Border FocusVisualStyle="{x:Null}"
                    Focusable="False">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <ContentPresenter Grid.Row="0"
                                      Content="{TemplateBinding DialogTop}" />
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="25*" />
                            <ColumnDefinition Width="50*" />
                            <ColumnDefinition Width="25*" />
                        </Grid.ColumnDefinitions>
                        <!--  Content area  -->
                        <Grid Grid.Column="1"
                              Margin="0 10 0 0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Row="0"
                                       FontSize="26"
                                       Foreground="{TemplateBinding Foreground}"
                                       Text="{TemplateBinding Title}"
                                       TextWrapping="Wrap" />
                            <ContentPresenter x:Name="PART_DialogBody_ContentPresenter"
                                              Grid.Row="1"
                                              Content="{TemplateBinding DialogBody}"
                                              DataContext="{TemplateBinding DataContext}" />
                        </Grid>
                    </Grid>
                    <ContentPresenter Grid.Row="2"
                                      Content="{TemplateBinding DialogBottom}" />
                </Grid>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <EventTrigger RoutedEvent="Loaded">
                <EventTrigger.Actions>
                    <BeginStoryboard Storyboard="{StaticResource DialogShownStoryboard}" />
                </EventTrigger.Actions>
            </EventTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type Dialogs:BaseMetroDialog}">
        <Setter Property="Template"
                Value="{StaticResource MetroDialogTemplate}" />
        <Setter Property="VerticalAlignment"
                Value="Center" />
        <Setter Property="HorizontalAlignment"
                Value="Stretch" />
        <Setter Property="Background"
                Value="{DynamicResource WhiteColorBrush}" />
        <Setter Property="Foreground"
                Value="{DynamicResource BlackBrush}" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="KeyboardNavigation.TabNavigation"
                Value="Cycle" />
        <Setter Property="KeyboardNavigation.DirectionalNavigation"
                Value="Cycle" />
        <Setter Property="Opacity"
                Value="0" />
    </Style>
</ResourceDictionary>